package ten;

public class Problem9 {
    public static void main(String args[]){
        int i=1,a=0,b=0,c=0,temp=0;
        while(true){
            if(i%2 == 1){
                a = i*2 + 1;
                b = (i*i)*2 + i*2;
                c = b +1;
            }
            else{
                a = i*2;
                b = i*i - 1;
                c = b + 2;
            }
            temp = 1000%(a+b+c);
            if(temp == 0){
                temp = 1000/(a+b+c);
                System.out.println(a*b*c*temp*temp*temp);
                System.exit(0);
            }
            else if(a+b+c<1000){
                i++;
            }
            else{
                break;
            }
            
        }
    }
}
